#!/bin/sh

# Make sure there are some keys...
if [ ! -f /etc/dropbear/dropbear_rsa_host_key ]; then
  mkdir -p /etc/dropbear
  /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
  /usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
fi

# Handle options...
case "$1" in
  'start')
    exec /usr/bin/dropbear -b /usr/libexec/dropbear-banner
    ;;
  'stop')
    echo
    echo " * Stopping SSH-2.0-dropbear_0.51..."
    echo 
    echo "   Just kidding... Restarting SSH-2.0-dropbear_0.51 would kick you out... That's silly"
    echo
    echo "   If you really want to cut the branch you are sitting on. Run this command: "
    echo
    echo "      sudo kill \`ps awx | grep dropbear | awk '{print $1}'\`"
    echo
    ;;
  'restart')
    echo
    echo " * Restarting SSH-2.0-dropbear_0.51..."
    echo 
    echo "   Just kidding... Restarting SSH-2.0-dropbear_0.51 would kick you out... That's silly"
    echo
    echo "   If you really want to cut the branch you are sitting on. Run this command: "
    echo
    echo "      sudo kill \`ps awx | grep dropbear | awk '{print $1}'\`"
    echo 
    ;;
  *)
    echo
    echo "   WTF...? Obviously (since you are here), SSH-2.0-dropbear_0.51 is already running..."
    echo
    ;;
esac

